home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / SampleCode / Modeller ƒ / Modeller_windows.c < prev    next >
Encoding:
Text File  |  1995-03-06  |  2.8 KB  |  132 lines  |  [TEXT/MPS ]

  1.  
  2. //
  3. //        windows.c
  4. //
  5. //        Window handling routines.
  6. //        
  7. //
  8. //        Author:        Rob Johnston
  9. //        Date:        Monday, January 20, 1992
  10. //
  11. //        Copyright © 1992-94 Apple Computer, Inc., All Rights Reserved
  12. //
  13. //
  14.  
  15.  
  16. #include "Modeller_globals.h"
  17. #include "Modeller_prototypes.h"
  18.  
  19. #include "Modeller_windows.h"
  20. #include "Modeller_camera.h"
  21. #include "Modeller_offscreen.h"
  22.  
  23.  
  24. //
  25. //    UpdateWindow is called when an update event is received for a docuemnt
  26. //    window.
  27. //
  28.  
  29. void UpdateWindow(WindowPtr theWindow)
  30.  
  31. {
  32.     DocumentPtr    theDocument = GetDocumentFromWindow(theWindow) ;
  33.     GrafPtr        savedPort ;
  34.     
  35.     GetPort( &savedPort ) ;
  36.     if(theDocument!=nil) {
  37.         SetPort(theWindow);
  38.         
  39.         BeginUpdate(theWindow);
  40.     
  41. //        EraseRect(&theWindow->portRect);
  42.         DrawOffscreen(theDocument);
  43.         DrawOnscreen(theDocument);
  44.         DoDrawGrowIcon(theWindow);
  45.     
  46.         EndUpdate(theWindow);
  47.     }
  48.     SetPort( savedPort ) ;
  49. }
  50.  
  51.  
  52. //
  53. //    GrowDocumentWindow is called when the user clicks in the growRgn of a
  54. //    document window.
  55. //
  56.  
  57. void GrowDocumentWindow(WindowPtr theWindow, Point thePoint)
  58.  
  59. {    long        result;
  60.     Rect        sizeRect;
  61.     GrafPtr        savedPort ;
  62.  
  63. #ifdef PODIUM_APP
  64.     return ;
  65. #endif
  66.     
  67.     GetPort(&savedPort) ;
  68.     SetPort(theWindow) ;
  69.  
  70.     sizeRect = qd.screenBits.bounds;
  71.     
  72.     if (!(result = GrowWindow(theWindow, thePoint, &sizeRect)))
  73.         return;
  74.         
  75.     SizeWindow(theWindow, LoWord(result), HiWord(result), false);
  76.     
  77.     EraseRect(&theWindow->portRect);
  78.     InvalRect(&theWindow->portRect);
  79.     
  80.     if( ((DocumentPtr ) ((WindowPeek) theWindow)->refCon)->documentGroup )
  81.         AdjustCamera((DocumentPtr ) ((WindowPeek) theWindow)->refCon,
  82.                         theWindow->portRect.right - theWindow->portRect.left,
  83.                         theWindow->portRect.bottom - theWindow->portRect.top);
  84.     
  85.     UpdateWindow(theWindow);
  86.  
  87.     SetPort(savedPort) ;
  88. }
  89.  
  90.  
  91. //-------------------------------------------------------------------------------
  92. //    DoDrawGrowIcon
  93. //
  94. //    Draw the grow icon. We do this in such a way that the scrollbar lines are
  95. //    not drawn. Normally, when the Toolbox routine DrawGrowIcon is called,
  96. //    vertical and horizontal lines are also drawn indicating where the
  97. //    scrollbars will be drawn. We don’t have scrollbars, so we don’t want those
  98. //    lines drawn. We avoid them by setting the clipping region of the window to
  99. //    include the grow box only. We then call DrawGrowIcon, and restore the old
  100. //    clipping region before returning.
  101.  
  102. void    DoDrawGrowIcon(WindowPtr theWindow)
  103. {
  104.     Rect        iconRect;
  105.     RgnHandle    oldClip;
  106.  
  107.     // this slows animation for demos down a lot
  108.     // probably should say something like
  109.     // if( gUsingHardware && theDocument->animate)
  110.     if(gUsingHardware) {
  111.         return ;
  112.     }
  113. #ifdef PODIUM_APP
  114.     return ;
  115. #endif
  116.  
  117.     SetPort(theWindow);
  118.     oldClip = NewRgn();
  119.     GetClip(oldClip);
  120.  
  121.     iconRect = theWindow->portRect;
  122.     iconRect.top = iconRect.bottom - 15;
  123.     iconRect.left = iconRect.right - 15;
  124.     ClipRect(&iconRect);
  125.  
  126.     PenNormal();
  127.     DrawGrowIcon(theWindow);
  128.  
  129.     SetClip(oldClip);
  130.     DisposeRgn(oldClip);
  131. }
  132.